package io.tec.cloud.algorithm.c02_v20220606;

public class C02_Swap {

    public static void swap(int[] arr, int i, int j) {
        if (i == j) {
            throw new RuntimeException("使用异或交换数据时，两个索引不可以相同");
        }

        arr[i] = arr[i] ^ arr[j];
        arr[j] = arr[i] ^ arr[j];
        arr[i] = arr[i] ^ arr[j];
    }
}
